#include "gp.h"
#include "correspond.h"
#include "cg_image.h"

int
main(int argc, char *argv[])
{
    Correspond ctrl(TCP, RECV_PORT);
    Correspond getI(TCP, RECV_PORT);
    MessageType type;
    int i;
    char str[BUFF_MAXSIZE];
    CGImage image;

    if (argc < 3)
    {
	printf("Usage: ctrl -p/-w <IP> ... <IP>\n");
	return 0;
    }

    if (strcmp(argv[1], "-p") == 0) type = NODE_PAUSE;
    else if (strcmp(argv[1], "-w") == 0) type = NODE_WORK;
    else if (strcmp(argv[1], "-t") == 0) type = NODE_WORK;
    
    for (i = 2; i < argc; ++i)
    {
	ctrl.setHead("127.0.0.1", -1, argv[i], -1);
	ctrl.sendMessage(type, "");
	printf("#ctrl: send %d to %s\n", type, argv[i]);
    }

    /*if (strcmp(argv[1], "-t") == 0)
    {
	printf("end");
	getI.recvMessage(getI.listenPort());
	getI.getContent(str);
	puts(str);
	image.buildCGImage(str, ONLINE);
	image.printCGTree();
    }*/
    
    return 0;
}
